home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 886 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.7 KB  |  55 lines

  1. Path: chronicle.mti.sgi.com!austern
  2. From: kuehl@uzwil.informatik.uni-konstanz.de (Dietmar Kuehl)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Placement delete suggestion Keywords: delete placement
  5. Date: 27 Mar 1996 15:41:05 PST
  6. Organization: FakultΣt fⁿr Mathematik und Informatik
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4jc296$h0t@news.BelWue.DE>
  9. References: <4j4ec5$d41@fsgi01.fnal.gov> <9603261124.AA22276@lts.sel.alcatel.de> <4jboij$4t3@mulga.cs.mu.OZ.AU>
  10. Reply-To: dietmar.kuehl@uni-konstanz.de
  11. NNTP-Posting-Host: isolde.mti.sgi.com
  12. X-Original-Date: 27 Mar 1996 18:43:50 GMT
  13. X-Newsreader: TIN [version 1.2 PL2]
  14. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  15.     iQBVAwUBMVnSEky4NqrwXLNJAQFN2AH/Z22DzlQ4DbWL8898JZcLRSlcaD2cen8X
  16.     d6+KyOsBTp9Ug2vpw5KhOG2tIMGL3IdoXZeRStoIWsGnjxAOWZuIpw==
  17.     =/P/X
  18. Originator: austern@isolde.mti.sgi.com
  19.  
  20. Hi,
  21. Fergus Henderson (fjh@munta.cs.mu.OZ.AU) wrote:
  22. : Or is it?  On second thoughts, I think the work-around suggested in the ARM
  23. : of using a my_delete function won't work for array delete, since you
  24. : don't know how many elements to delete.  That is rather unfortunate --
  25. : it certainly limits the usefulness of placement array new.
  26.  
  27. OTOH, as Tim Hollebeek observed in a thread in comp.lang.c++.moderated
  28. (Placement new and arrays), the usefulness of placement array new is
  29. limited anyway: There is no portable way to figure out how much
  30. "allocation overhead" there will be and thus it is impossible to
  31. predict how much memory has to be set aside for a placement array new.
  32. In fact, it turns out that it is impossible to place an array at a
  33. specific address with placement new due to this allocation overhead:
  34. See the example in expr.new verse 12 of the April DWP: "... - 'new(2,f)
  35. T[5]' results in a call of 'operator new[](sizeof(T)*5+y,2,f)'. Here,
  36. 'x' and 'y' are non-negative, implementation-defined values
  37. represeneting array allocation overhead. They migh vary from one use of
  38. 'new' to another.". There is nothing said about the address of the
  39. first element of the array... The only portable way I know to place an
  40. array at a specific address in a chunk of memory whose size can be
  41. predicted, is to do it "by hand", i.e. using placement (non-array) new
  42. for each individual element of the array (and, of course, using
  43. explicit destructor calls to release the objects).
  44. --
  45. dietmar.kuehl@uni-konstanz.de
  46. http://www.informatik.uni-konstanz.de/~kuehl
  47. I am a realistic optimist - that's why I appear to be slightly pessimistic
  48. ---
  49. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  50.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  51.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  52.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  53.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  54. ]
  55.